Allow inserting HTML fragments in email templates #38093
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposal, this PR is here for discussions.
Email templates currently only allow to add text bodies, lists and buttons. It's not possible to add formatting or other elements. Also, text bodies are always centered, which can be hard to read when there a lot of text. This provides a way to inject arbitrary HTML in emails, which can be useful in some cases.
One of these cases I have is nextcloud/announcementcenter#644, which would be achieved otherwise by creating an
IMessage
from scratch, but that prevents consistency and theming.Right now the HTML fragment is really just injected in the HTML body, but we could validate (very basically, at a XML level) and sanitize it (using SF's HTML Sanitizer).
Another option is to allow for Markdown fragments directly, and do the rendering here (brings another specific dependency though).
TODO
tests/lib/Mail/EMailTemplateTest.php
Checklist